<template>
<div>
  <el-table v-loading="loading" :data="bookList" stripe>
    <el-table-column type="index" width="50"></el-table-column>
    <el-table-column prop="username" label="姓名"></el-table-column>
    <el-table-column prop="phone" label="电话"></el-table-column>
    <el-table-column prop="time" label="预约时间"></el-table-column>
    <el-table-column prop="count" label="预约人数"></el-table-column>
    <el-table-column prop="shop" label="店铺"></el-table-column>
    <el-table-column prop="bookitem" label="预约项目"></el-table-column>
    <el-table-column prop="message" label="预约信息"></el-table-column>
    <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" type="danger" @click="onDel(scope.row)">删除</el-button>
        </template>
      </el-table-column>
  </el-table>
     <!-- 确认删除对话框 -->
    <el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
      <span>确定删除该图片吗</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="doDel">确 定</el-button>
      </span>
    </el-dialog>
</div>

</template>

<script>
import { fetchList ,del} from '@/api/book'
export default {
  data() {
    return {
      bookList: [],
      loading: false,
      dialogVisible: false,
      book:{}
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.loading = true
      fetchList().then(res => {
        console.log(res.data)
        this.bookList = res.data
        this.loading = false
      })
    },
    onDel(row) {
      this.book = row
      this.dialogVisible = true
    },
    doDel() {
      this.loading = true
      del(this.book).then(res => {
        this.loading = false
        this.dialogVisible = false
        this.getList()
        this.$message({
          message: '删除成功',
          type: 'success'
        })
      })
    }
  }
}
</script>
<style>
</style>